

package uaem.tituaem.eventosgui;

import com.sun.glass.events.KeyEvent;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.KeyStroke;
import uaem.tituaem.gui.Login;
import uaem.tituaem.gui.Principal;


public class Eventos {
    
    private KeyStroke leerTeclas;
    private Action  accionTeclas;

    //constructor
    public Eventos() {
        
    }
    
    public void logIn(Principal padre)
    {
        leerTeclas = KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK);
        accionTeclas = new AbstractAction()
        {

            @Override
            public void actionPerformed(ActionEvent e) 
            {
                if(!padre.checkBotones())
                {
                Login logeame = new Login(padre, true);
                logeame.setVisible(true);
                }
                
                
                
            }
            
        };
        
        padre.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(leerTeclas, "Abrir");
        padre.getRootPane().getActionMap().put("Abrir", accionTeclas);
    }
    
    public void logOut(Principal padre)
    {
        leerTeclas = KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK);
        accionTeclas = new AbstractAction()
        {

            @Override
            public void actionPerformed(ActionEvent e) 
            {
                
               padre.deshabilitarBotones();
                
                
            }
            
        };
        
        padre.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(leerTeclas, "Salir");
        padre.getRootPane().getActionMap().put("Salir", accionTeclas);
    }
    
    
}
